

using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Specialized;
using System.Collections.Generic;
using JTC.MiniCommerce.Core;
using JTC.MiniCommerce.Core.Configuration;
using JTC.MiniCommerce.Localization;
using JTC.MiniCommerce.Store.Services;
using JTC.MiniCommerce.Store.Services.PaymentService;

namespace JTC.MiniCommerce.Web.admin {
  public partial class paymentserviceconfiguration : System.Web.UI.Page {

    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
    }

    /// <summary>
    /// Handles the Click event of the btnSave control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void btnSave_Click(object sender, EventArgs e) {
      try {
        PaymentServiceSettings paymentServiceSettings = new PaymentServiceSettings();
        ProviderSettings settings = new ProviderSettings();
        settings.Name = typeof(PayPalProPaymentProvider).Name;
        settings.Type = typeof(PayPalProPaymentProvider).AssemblyQualifiedName;
        settings.Parameters.Add("ApiUserName", "username");
        settings.Parameters.Add("ApiPassword", "password");
        settings.Parameters.Add("Signature", "signature");
        settings.Parameters.Add("IsLive", "false");
        paymentServiceSettings.ProviderSettingsCollection.Add(settings);
        DatabaseConfigurationProvider config = new DatabaseConfigurationProvider();
        config.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, WebUtility.GetUserName());
      }
      catch (Exception ex) {
        Logger.Error(typeof(paymentserviceconfiguration).Name + ".Page_Load", ex);
        Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message));
      }
    }

    #endregion

  }
}
